package cn.edu.nuc.ssm.controller;

import cn.edu.nuc.ssm.dto.*;
import cn.edu.nuc.ssm.service.ReportService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * Created by Administrator on 2017/4/15.
 */

@Controller
@RequestMapping("/report")
public class ReportController {

    @Autowired
    private ReportService reportService;

    @RequestMapping("/index")
    public String index(){
        return "front/report_index";
    }
    @RequestMapping("/reportshouzhi")
    public String reportShouzhi(){
        return "front/report_shouzhi";
    }
    @RequestMapping("/categoryreport")
    public String categoryReport(){
        return "front/report_category";
    }
    @RequestMapping("/analysereport")
    public String analyseReport(){
        return "front/report_analyse";
    }

    /*以上是一些页面的跳转*/

    @ResponseBody
    @RequestMapping(value = "/sumshouzhidata",method= RequestMethod.POST)
    public SumShouZhiDto sumShouZhiData(int uid,String year){

        SumShouZhiDto sumShouZhiDto = reportService.sumShouZhi(uid, year);

        return sumShouZhiDto;
    }

    @ResponseBody
    @RequestMapping(value = "/sumjidushouzhidata",method = RequestMethod.POST)
    public SumjiduShouZhiDto sumJiduShouZhiData(int uid , String year){

        SumjiduShouZhiDto sumjiduShouZhiDto = reportService.sumShouZhiByJidu(uid, year);
        return sumjiduShouZhiDto;
    }

    @ResponseBody
    @RequestMapping(value = "/summonthshouzhidata",method = RequestMethod.POST)
    public SumMonthShouZhiDto sumMonthShouZhiDto(int uid , String year){

        SumMonthShouZhiDto sumMonthShouZhiDto = reportService.sumShouZhiByMonth(uid, year);
        return sumMonthShouZhiDto;
    }

    @ResponseBody
    @RequestMapping(value = "/sumyeartypezhidata",method = RequestMethod.POST)
    public ZhiTypeNameAndmoneyArrDto sumfindbyUidSumZhiByYearAndType(int uid , String year){

        ZhiTypeNameAndmoneyArrDto zhiTypeNameAndmoneyArrDto = reportService.sumfindbyUidSumZhiByYearAndType(uid, year);
        return zhiTypeNameAndmoneyArrDto;
    }

    @ResponseBody
    @RequestMapping(value = "/summonthtypezhidata",method = RequestMethod.POST)
    public ZhiTypeNameAndmoneyArrDto sumfindbyUidSumZhiByMonthAndType(int uid , String year,String month){

        ZhiTypeNameAndmoneyArrDto zhiTypeNameAndmoneyArrDto = reportService.sumfindbyUidSumZhiByMonthAndType(uid, year,month);
        return zhiTypeNameAndmoneyArrDto;
    }

    @ResponseBody
    @RequestMapping(value = "/sumjidutypezhidata",method = RequestMethod.POST)
    public ZhiTypeNameAndmoneyArrDto sumfindbyUidSumZhiByJiduAndType(int uid , String year,Integer quarter){

        ZhiTypeNameAndmoneyArrDto zhiTypeNameAndmoneyArrDto = reportService.sumfindbyUidSumZhiByJiduAndType(uid, year,quarter);
        return zhiTypeNameAndmoneyArrDto;
    }

    @ResponseBody
    @RequestMapping(value = "/fenxitypezhidata",method = RequestMethod.POST)
    public ConsumeAnalyDtoArr fenxiZhiByUidAndType(int uid , String year){

        ConsumeAnalyDtoArr consumeAnalyDtoArr = reportService.fenxiZhiByUidAndType(uid, year);
        return consumeAnalyDtoArr;
    }

    @ResponseBody
    @RequestMapping(value = "/fenxitypezhiavgdata",method = RequestMethod.POST)
    public ConsumeAnalyDtoArr fenxiZhiByTypeAvg( String year){

        ConsumeAnalyDtoArr consumeAnalyDtoArr = reportService.fenxiZhiByType(year);
        return consumeAnalyDtoArr;
    }




}
